package cn.jiyun.service.impl;

import cn.jiyun.dao.DdMapper;
import cn.jiyun.entity.PageResult;
import cn.jiyun.entity.QueryPageBean;
import cn.jiyun.pojo.Dd;
import cn.jiyun.service.DdService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

@Service
public class DdServiceImpl implements DdService {
    @Autowired
   private DdMapper ddMapper;
    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<Map> page=ddMapper.findPage(queryPageBean.getQueryString());
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void add(Dd dd) {
        ddMapper.insert(dd);
    }

    @Override
    public void update(Dd dd) {
        ddMapper.updateByPrimaryKey(dd);
    }

    @Override
    public void delete(Integer id) {
        ddMapper.deleteByPrimaryKey(id);

    }


}
